package com.qzyh.esb.egsa.controller;

import com.qzyh.esb.egsa.bean.dto.LoginRspDTO;
import com.qzyh.esb.egsa.bean.dto.PublicKeyDTO;
import com.qzyh.esb.egsa.bean.vo.LoginReqVO;
import com.qzyh.esb.egsa.config.JwtConfig;
import com.qzyh.esb.egsa.service.ILoginService;
import com.qzyh.esb.egsa.utils.ResultObject;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(value = "登录Controller", tags = { "登录接口" })
@RestController
@RequestMapping("/login")
public class LoginController {

    private static final Logger logger = LoggerFactory.getLogger(LoginController.class);

    @Autowired
    private ILoginService loginService;

    @PostMapping("/publicKey")
    @ApiOperation(value = "生成公钥")
    public ResultObject<PublicKeyDTO> publicKey() {
        PublicKeyDTO publicKeyDTO = loginService.genPublicKey();
        return ResultObject.success(publicKeyDTO);
    }

    @PostMapping("/index")
    @ApiOperation(value = "登录")
    public ResultObject<LoginRspDTO> index(@RequestBody LoginReqVO vo) {
        return loginService.login(vo);
    }
}